import request, { PROXY_URL } from '@/config/axios'
// 登录
export const putLogin = (code,data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}${code}/login` ,data})
}
// 退出登录
export const putLogout = (): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}logout`})
}


// 获取系统信息
export const getResourceConditionAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemMonitor/resourceCondition` })
}
export const getResourceRealtimeAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemMonitor/resourceRealtime` })
}
// 获取某一天的所有监测信息
export const getStatisticInfosAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemMonitor/getStatisticInfos` ,params})
}
// Lastlog命令输出记录

export const lastLogOutput = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemManage/log/lastLogOutput` })
}
// 获取面板基础设施信息
export const getInfrastructureInfoAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemManage/panel/getInfrastructureInfo` })
}


// 获取面板操作日志
export const getPanelLogAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemManage/panel/getPanelLog` })
}

// 列出所有数据库信息
export const getSchemasAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}appManage/mysql/showSchemas`, params })
}

// 更新Root密码
export const setUpdateRootKeyAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/mysql/updateRootKey`, data })
}

// 创建数据库并配置用户
export const setCreateSchemaAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/mysql/createSchema`, data })
}

// 添加FTP账户
export const setAddUserFTPAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/FTP/addUser`, data })
}
// 列出所有FTP用户
export const getListAllUsersFTPAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}appManage/FTP/listAllUsers`, params })
}

// 添加TCP端口策略
export const setAddPortTCPFireWallAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/fireWall/addPortTCP`, data })
}

// 安装firewalld
export const setinstallFireWallAPI = (): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}systemManage/fireWall/install`, isShowLoading: true, lableLoading: "安装中...." })
}

// 防火墙服务管理
export const setSystemctlFireWallAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}systemManage/fireWall/systemctl`, data })
}

// 列出防火墙策略
export const getListAllFireWallAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemManage/fireWall/listAll`, params, isShowErr: false })
}

// 添加TCP端口策略
export const setAddPortFireWallAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}systemManage/fireWall/addPort`, data })
}
// 移除TCP端口IP策略
export const setRemovePortFireWallAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}systemManage/fireWall/removePort`, data })
}
// 移除所有TCP端口策略
export const getRemoveAllPortTCPFireWallAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemManage/fireWall/removeAllPortTCP`, params })
}
// 查看某个端口的占用状态
export const getPortOccupancyFireWallAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemManage/fireWall/portOccupancy`, params })
}
// 生效策略（重载配置)
export const putSystemctlFireWallAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}systemManage/fireWall/systemctl`, data })
}

//查看系统时间状态
export const getTimeStatusAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}systemManage/time/getTimeStatus` })
}


// 商店页面展示
export const getAppManageListAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}appManage/list`, params })
}

// 软件安装
export const putAppManageInstallAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/install`, data, isShowLoading: true, lableLoading: "安装中...." })
}

//软件服务
export const putAppManageSystemctlAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/systemctl`, data, })
}



//获取mysql配置文件
export const getAppMysqlGetConfigAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}appManage/mysql/getConfig` })
}
//更新mysql配置文件
export const putAppMysqlSetConfigAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/mysql/setConfig`, data })
}

//获取全局永久MySQL性能参数
export const getGlobalPerformanceParamsPermanentAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}appManage/mysql/getGlobalPerformanceParamsPermanent` })
}
//更新全局永久MySQL性能参数
export const setGlobalPerformanceParamsPermanentAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/mysql/setGlobalPerformanceParamsPermanent`, data })
}


//获取Redis配置文件
export const getAppManageRedisGetConfigAPI = (): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}appManage/redis/getConfig` })
}

//更新Redis配置文件
export const putAppManageRedisSetConfigAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}appManage/redis/setConfig`, data })
}

//获取Nginx信息及日志
export const getNginxInfoAPI = (params): Promise<IResponse> => {
  return request.get({ url: `${PROXY_URL}appManage/nginx/getNginxInfo` ,params})
}
// 更新Nginx的Config
export const putAppManageNginxSetConfigAPI = (data): Promise<IResponse> => {
  return request.post({ url: `${PROXY_URL}/appManage/nginx/setConfig`, data })
}


